﻿<?php 
	function xac_dinh_menu_con__123($id_cha)
	{
		$tv="select count(*) from menu where thuoc_menu='$id_cha'";
		$tv_1=mysql_query($tv);
		$tv_2=mysql_fetch_row($tv_1);
		if($tv_2[0]==0)
		{
			return "khong";
		}
		else 
		{
			return "co";
		}
	}
	function de_quy_menu__fff($id_cha)
	{
		$tv="select * from menu where thuoc_menu='$id_cha'";
		$tv_1=mysql_query($tv);
		while($tv_2=mysql_fetch_array($tv_1))
		{
			$link="$tv_2[link]";
			echo "<li class='children'>";
				echo "<a $link>";
					echo $tv_2['ten'];
				echo "</a>";
				$xac_dinh_menu_con__123=xac_dinh_menu_con__123($tv_2['id']);
				if($xac_dinh_menu_con__123=="co")
				{				
					echo "<ul>";
						de_quy_menu__fff($tv_2['id']);
					echo "</ul>";
										
				}
			echo "</li>";
		}	
	}
?>
<div>
	<ul id="menu">	
			<?php 
				$tv="select * from menu where thuoc_menu=''";
				$tv_1=mysql_query($tv);
				while($tv_2=mysql_fetch_array($tv_1))
				{
					$link="$tv_2[link]";
					echo "<li class='drop'>";		
						echo "<a $link>";						
							echo $tv_2['ten'];
						echo "</a>";
						$xac_dinh_menu_con__123=xac_dinh_menu_con__123($tv_2['id']);
						if($xac_dinh_menu_con__123=="co")
						{
							echo "<div class='dropdown_view'>";
								echo "<div class='col_view'>";
									echo "<ul>";
										de_quy_menu__fff($tv_2['id']);
									echo "</ul>";
								echo "</div>";
							echo "</div>";		
						}
					echo "</li>";
				}
			?>
			<?php 
				include("popupmenu.php");
			?>		
	</ul>
</div>
